import request from '@/utils/request'

// 登录
export const login = (data) => {
  return request({
    method: 'post',
    url: '/private/v1/login',
    data,
  })
}
// 获取用户列表
export const getUserList = (params) => {
  return request({
    method: 'get',
    url: '/private/v1/users',
    params,
  })
}
// 添加用户
export const addUser = (data) => {
  return request({
    method: 'post',
    url: '/private/v1/users',
    data,
  })
}

// 获取单个用户
export const getUserDetail = (id) => {
  return request({
    method: 'get',
    url: '/private/v1/users/' + id,
  })
}
// 修改用户
export const editUserDetail = (id, data) => {
  return request({
    method: 'put',
    url: `/private/v1/users/${id}`,
    data,
  })
}
// 删除用户
export const delUser = (id) => {
  return request({
    method: 'delete',
    url: `/private/v1/users/${id}`,
  })
}
// 分配角色
export const distributeUser = (id) => {
  return request({
    method: 'get',
    url: '/private/v1/roles',
    query: { id },
  })
}
// 修改角色
export const changeRoles = (id, data) => {
  return request({
    method: 'put',
    url: `/private/v1/users/${id}/role`,
    data,
  })
}
// 更改用户状态
export const changeUserState = (id, state) => {
  return request({
    method: 'put',
    url: `/private/v1/users/${id}/state/${state}`,
  })
}
